package pers.uang.crud.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pers.uang.crud.mapper.EmployeeMapper;
import pers.uang.crud.pojo.Employee;
import pers.uang.crud.service.EmployeeService;

import java.util.List;


@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public PageInfo<Employee> getAllEmpByPage(Integer pageNum) {
        Page<Object> page = PageHelper.startPage(pageNum, 4);
        List<Employee> emps = employeeMapper.getAllEmployee();
        return new PageInfo<>(emps, 5);
    }

    @Override
    public List<Employee> getAllEmployee() {
        return employeeMapper.getAllEmployee();
    }

    @Override
    public void addEmployee(Employee employee) {
        employeeMapper.addEmployee(employee);
    }

    @Override
    public Employee getEmployeeById(Integer empId) {
        return employeeMapper.getEmployeeById(empId);
    }

    @Override
    public void updateEmployee(Employee employee) {
        employeeMapper.updateEmployee(employee);
    }

    @Override
    public void deleteEmployeeById(Integer empId) {
        employeeMapper.deleteEmployeeById(empId);
    }

    @Override
    public void batchDelEmp(String empItems) {
        employeeMapper.batchDelEmp(empItems);
    }
}
